package com.qinggeng.project.system.service.impl;

import com.google.common.collect.Lists;
import com.qinggeng.project.system.domain.SysRoleMenu;
import com.qinggeng.project.system.mapper.SysRoleMenuMapper;
import com.qinggeng.project.system.service.ISysRoleMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysRoleMenuServiceImpl implements ISysRoleMenuService {
    @Resource
    private SysRoleMenuMapper sysRoleMenuMapper;

    @Override
    public int insertSysRoleMenu(Long roleId, Long menuId) {
        SysRoleMenu sysRoleMenu=new SysRoleMenu();
        sysRoleMenu.setRoleId(roleId);
        sysRoleMenu.setMenuId(menuId);
        if(sysRoleMenuMapper.checkIsExisted(sysRoleMenu)){
            return 0;
        }
        List<SysRoleMenu> sysRoleMenuList= Lists.newArrayList();
        sysRoleMenuList.add(sysRoleMenu);
        return sysRoleMenuMapper.batchRoleMenu(sysRoleMenuList);
    }
}
